<?php
use application\Comm\Func;
$img_path = Func::getImageCdnRand();
$lable = isset($lable)?$lable:'图片';
$dir_id = isset($dir_id)?$dir_id:2;
$iswater = isset($iswater)?$iswater:0;
$name = isset($name)?$name:'src';
?>
<script type="text/javascript">
    function doc_upload_success_one_<?php echo $name?>(file, data) {
        var json = $.parseJSON(data)

        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#pic_show_one_<?php echo $name?>').html('<div class="item"> <div class="info"><span class="up_cancel" title="取消上传"><i class="fa fa-times-circle-o"></i></span></div><div class="preview"> <span class="img"> <img src="<?php echo $img_path;?>'+json.filename+'"> </span> </div><div style="margin-top:5px"></div> ')
            $('#pic_show_one_<?php echo $name?>').append('<input type="hidden" name="info[src]" value="' + json.filename + '" /></div>')
            $('.up_cancel').click(function(){
                $(this).parent().parent().remove();
            });
        }
    }
</script>
<tr>
    <td colspan="2">
        <label class="control-label x100"><?php echo $lable?>：</label>
        <div style="display:inline-block; vertical-align:top;">
            <div id="<?php echo $name?>"  data-toggle="upload" data-uploader="<?php echo Func::createUrl('site/upload',['iswater'=>$iswater,'d'=>$dir_id])?>"
                 data-file-size-limit="1024000000"
                 data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
                 data-multi="false"
                 data-auto="true"
                 data-previewImg="true"
                 data-on-upload-success="doc_upload_success_one_<?php echo $name?>"
                 data-icon="cloud-upload"></div>
        </div>

    </td>
</tr>
<tr>
    <td colspan="2">
        <label class="control-label x100"></label>
        <div style="display:inline-block; vertical-align:top;">
            <div class="bjui-upload">
                <div class="queue" style="display: block;" id="pic_show_one_<?php echo $name?>">
                    <?php if(isset($info)){?>
                    <div class="item">
                        <div class="preview">

                            <span class="img">
                                <img src="<?php echo $img_path.$info[$name]?>">
                            </span>
                            <input type="hidden" name="info[<?php echo $name?>]" value="<?php echo $info[$name]?>" />
                        </div>
                    </div>
                    <?php }?>

            </div>
        </div>

    </td>
</tr>